/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.controller;

import com.minierp.bean.InBillBean;
import com.minierp.bean.InBillItemBean;
import com.minierp.bean.OrderParameterCarrier;
import com.minierp.bean.QueryParameterBean;
import com.minierp.bean.QueryResult;
import com.minierp.bean.UserBean;
import com.minierp.dao.BusinessBillDao;
import com.minierp.dao.CodeRuleDao;
import com.minierp.dao.IdGenerator;
import com.minierp.dao.InBillDao;
import com.minierp.dao.InBillItemDao;
import com.minierp.dao.InTypeDao;
import com.minierp.dao.ProductDao;
import com.minierp.dao.QueryDao;
import com.minierp.dao.StockBalanceDao;
import com.minierp.dao.StockDao;
import com.minierp.dao.StorehouseDao;
import com.minierp.dao.TallySetDao;
import com.minierp.err.PermissionDennyException;
import com.minierp.err.StockNoEnoughException;
import com.minierp.helper.EncCommonHelper;
import com.minierp.helper.EncInBillMACtrHelper;
import com.minierp.helper.PageHelper;
import com.minierp.model.Department;
import com.minierp.model.EnterpriseInfo;
import com.minierp.model.Establishment;
import com.minierp.model.InBill;
import com.minierp.model.InBillItem;
import com.minierp.model.Product;
import com.minierp.model.Storehouse;
import com.minierp.model.TallySet;
import com.minierp.model.WorkCenter;
import com.minierp.service.InBillService;
import com.minierp.view.InBillListExcelView;
import com.minierp.view.InBillTemplateExcelView;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.springframework.dao.CannotAcquireLockException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class InBillMACtr extends MultiActionController {
	private InBillDao inBillDao;
	private InBillItemDao inBillItemDao;
	private ProductDao productDao;
	private StockDao stockDao;
	private StockBalanceDao stockBalanceDao;
	private InTypeDao inTypeDao;
	private StorehouseDao storehouseDao;
	private QueryDao queryDao;
	private BusinessBillDao businessBillDao;
	private TallySetDao tallySetDao;
	private CodeRuleDao codeRuleDao;
	private IdGenerator idGenerator;
	private InBillService inBillService;
	private DataSource dataSource;
	private String dialogSuccessView;
	private String listForExamineView;
	private String infoForExamineView;
	private String listForUnExamineView;
	private String infoForUnExamineView;
	private String listForCancelView;
	private String infoForCancelView;
	private String searchResultView;
	private String printView;
	private String uploadFormView;

	public String getUploadFormView() {
		return this.uploadFormView;
	}

	public void setUploadFormView(String uploadFormView) {
		this.uploadFormView = uploadFormView;
	}

	public String getSearchResultView() {
		return this.searchResultView;
	}

	public void setSearchResultView(String searchResultView) {
		this.searchResultView = searchResultView;
	}

	public String getDialogSuccessView() {
		return this.dialogSuccessView;
	}

	public void setDialogSuccessView(String dialogSuccessView) {
		this.dialogSuccessView = dialogSuccessView;
	}

	public InBillDao getInBillDao() {
		return this.inBillDao;
	}

	public void setInBillDao(InBillDao inBillDao) {
		this.inBillDao = inBillDao;
	}

	public InBillItemDao getInBillItemDao() {
		return this.inBillItemDao;
	}

	public void setInBillItemDao(InBillItemDao inBillItemDao) {
		this.inBillItemDao = inBillItemDao;
	}

	public String getInfoForCancelView() {
		return this.infoForCancelView;
	}

	public void setInfoForCancelView(String infoForCancelView) {
		this.infoForCancelView = infoForCancelView;
	}

	public String getInfoForExamineView() {
		return this.infoForExamineView;
	}

	public void setInfoForExamineView(String infoForExamineView) {
		this.infoForExamineView = infoForExamineView;
	}

	public String getInfoForUnExamineView() {
		return this.infoForUnExamineView;
	}

	public void setInfoForUnExamineView(String infoForUnExamineView) {
		this.infoForUnExamineView = infoForUnExamineView;
	}

	public String getListForCancelView() {
		return this.listForCancelView;
	}

	public void setListForCancelView(String listForCancelView) {
		this.listForCancelView = listForCancelView;
	}

	public String getListForExamineView() {
		return this.listForExamineView;
	}

	public void setListForExamineView(String listForExamineView) {
		this.listForExamineView = listForExamineView;
	}

	public String getListForUnExamineView() {
		return this.listForUnExamineView;
	}

	public void setListForUnExamineView(String listForUnExamineView) {
		this.listForUnExamineView = listForUnExamineView;
	}

	public ProductDao getProductDao() {
		return this.productDao;
	}

	public void setProductDao(ProductDao productDao) {
		this.productDao = productDao;
	}

	public ModelAndView handleListForExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "IN_EXAM")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listForExamineView);
			String searchKey = request.getParameter("search_key");
			String tsId = request.getParameter("ts_id");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List tsList = PageHelper.getTallySetList(this.tallySetDao, ub);
			int perPageNum = EncCommonHelper.getPageSize(request);
			int total = this.inBillDao.getListCount(searchKey, false,
					Long.parseLong(tsId), ub, allowStart);
			int pageno = EncCommonHelper.getCurrentPageIndex(request, total,
					perPageNum);
			int startIndex = (pageno - 1) * perPageNum;
			List list = this.inBillDao.getList(searchKey, false,
					Long.parseLong(tsId), ub, allowStart, startIndex,
					perPageNum);
			List arr = this.parseInBill(list, this.inTypeDao.getList(false),
					this.storehouseDao.getList(false));
			mv.addObject("qr", EncCommonHelper.parseQueryResult(arr, total,
					perPageNum, pageno));
			mv.addObject("searchKey", searchKey);
			mv.addObject("tsId", tsId);
			mv.addObject("tsList", tsList);
			return mv;
		}
	}

	public ModelAndView handleInfoForExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.infoForExamineView);
		String id = request.getParameter("id");
		mv.addObject("record", this.getInBill(Long.parseLong(id)));
		return mv;
	}

	public ModelAndView handleListForUnExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "IN_UN_EXAM")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listForUnExamineView);
			String searchKey = request.getParameter("search_key");
			String tsId = request.getParameter("ts_id");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List tsList = PageHelper.getTallySetList(this.tallySetDao, ub);
			int perPageNum = EncCommonHelper.getPageSize(request);
			int total = this.inBillDao.getListCount(searchKey, true,
					Long.parseLong(tsId), ub, allowStart);
			int pageno = EncCommonHelper.getCurrentPageIndex(request, total,
					perPageNum);
			int startIndex = (pageno - 1) * perPageNum;
			List list = this.inBillDao.getList(searchKey, true,
					Long.parseLong(tsId), ub, allowStart, startIndex,
					perPageNum);
			List arr = this.parseInBill(list, this.inTypeDao.getList(false),
					this.storehouseDao.getList(false));
			mv.addObject("qr", EncCommonHelper.parseQueryResult(arr, total,
					perPageNum, pageno));
			mv.addObject("searchKey", searchKey);
			mv.addObject("tsId", tsId);
			mv.addObject("tsList", tsList);
			return mv;
		}
	}

	public ModelAndView handleInfoForUnExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.infoForUnExamineView);
		String id = request.getParameter("id");
		mv.addObject("record", this.getInBill(Long.parseLong(id)));
		return mv;
	}

	public ModelAndView handleListForCancel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "IN_CANC")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listForCancelView);
			String searchKey = request.getParameter("search_key");
			String tsId = request.getParameter("ts_id");
			UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
			if (tsId == null || tsId.equals("")) {
				tsId = String.valueOf(ub.getUser().getDfTsId());
			}

			Date allowStart = null;
			if (EncCommonHelper.checkPurePrivilege(request, "NO_EARL_DATA")) {
				allowStart = EncCommonHelper.getEarlDataDate(request);
			}

			List tsList = PageHelper.getTallySetList(this.tallySetDao, ub);
			int perPageNum = EncCommonHelper.getPageSize(request);
			int total = this.inBillDao.getListForCancelCount(searchKey,
					Long.parseLong(tsId), ub, allowStart);
			int pageno = EncCommonHelper.getCurrentPageIndex(request, total,
					perPageNum);
			int startIndex = (pageno - 1) * perPageNum;
			List list = this.inBillDao.getListForCancel(searchKey,
					Long.parseLong(tsId), ub, allowStart, startIndex,
					perPageNum);
			List arr = this.parseInBill(list, this.inTypeDao.getList(false),
					this.storehouseDao.getList(false));
			mv.addObject("qr", EncCommonHelper.parseQueryResult(arr, total,
					perPageNum, pageno));
			mv.addObject("searchKey", searchKey);
			mv.addObject("tsId", tsId);
			mv.addObject("tsList", tsList);
			return mv;
		}
	}

	public ModelAndView handleInfoForCancel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.infoForCancelView);
		String id = request.getParameter("id");
		mv.addObject("record", this.getInBill(Long.parseLong(id)));
		return mv;
	}

	public ModelAndView handleExamine(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.dialogSuccessView);
		UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
		String idStr = request.getParameter("id_str");
		String flag = request.getParameter("flag");
		boolean examined = false;
		if (flag != null && flag.equals("1")) {
			examined = true;
		}

		String[] arr = idStr.split(";");
		boolean num = false;
		String msg;
		int se;
		byte arg15;
		if (!examined) {
			if (!EncCommonHelper.checkPrivilege(request, "IN_UN_EXAM")) {
				throw new Exception("Permission deny!");
			}

			try {
				for (se = 0; se < arr.length; ++se) {
					this.inBillService.txUnExamine(Long.parseLong(arr[se]),
							this.inBillDao, this.inBillItemDao, this.stockDao,
							this.stockBalanceDao, this.businessBillDao,
							this.idGenerator, ub);
				}

				msg = "反审核成功";
			} catch (StockNoEnoughException arg13) {
				msg = arg13.getMessage();
			} catch (CannotAcquireLockException arg14) {
				msg = "事务冲突故障，请重新操作。";
			}

			arg15 = 1;
		} else {
			if (!EncCommonHelper.checkPrivilege(request, "IN_EXAM")) {
				throw new Exception("Permission deny!");
			}

			try {
				for (se = 0; se < arr.length; ++se) {
					this.inBillService.txExamine(Long.parseLong(arr[se]),
							this.inBillDao, this.inBillItemDao, this.stockDao,
							this.stockBalanceDao, this.businessBillDao,
							this.idGenerator, ub);
				}

				msg = "审核成功";
			} catch (StockNoEnoughException arg11) {
				msg = arg11.getMessage();
			} catch (CannotAcquireLockException arg12) {
				msg = "事务冲突故障，请重新操作。";
			}

			arg15 = 1;
		}

		mv.addObject("returnValue", String.valueOf(arg15));
		EncCommonHelper.setAlertMessage(request, msg);
		return mv;
	}

	public ModelAndView handleCancel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.dialogSuccessView);
		UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
		if (!EncCommonHelper.checkPrivilege(request, "IN_CANC")) {
			throw new Exception("Permission deny!");
		} else {
			String id = request.getParameter("id");
			String reason = request.getParameter("reason");
			String msg = "";

			try {
				this.inBillService.txCancel(Long.parseLong(id), reason,
						this.inBillDao, this.inBillItemDao, this.stockDao,
						this.stockBalanceDao, this.businessBillDao,
						this.idGenerator, ub);
				msg = "作废成功";
			} catch (StockNoEnoughException arg8) {
				msg = arg8.getMessage();
			} catch (CannotAcquireLockException arg9) {
				msg = "事务冲突故障，请重新操作。";
			}

			mv.addObject("returnValue", id);
			EncCommonHelper.setAlertMessage(request, msg);
			return mv;
		}
	}

	public ModelAndView handleSearchResult(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "IN_BILL_SEAR")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			String contentType = request.getParameter("content_type");
			QueryParameterBean b = EncInBillMACtrHelper.handleSearchResultCost(
					request, this.dataSource);
			QueryResult qr = this.queryDao.doQuery(b.getQParas(),
					(OrderParameterCarrier[]) null, (String[]) null,
					b.getShortNameMap(), b.getRetObjs(), (String[]) null);
			List list = qr.getList();
			String costTotal = "0";
			if (!list.isEmpty() && list.get(0) != null) {
				costTotal = list.get(0).toString();
			}

			b = EncInBillMACtrHelper.handleSearchResult(request,
					this.dataSource);
			if (contentType != null && contentType.equals("EXCEL")) {
				qr = this.queryDao.doQuery(b.getQParas(), b.getOParas(),
						(String[]) null, b.getShortNameMap(), b.getRetObjs(),
						(String[]) null);
				list = this.parseInBill(qr.getList(),
						this.inTypeDao.getList(false),
						this.storehouseDao.getList(false));
				qr.setList(list);
				InBillListExcelView mv1 = new InBillListExcelView();
				HashMap ub1 = new HashMap();
				ub1.put("list", qr.getList());
				ub1.put("costTotal", costTotal);
				return new ModelAndView(mv1, ub1);
			} else {
				qr = this.queryDao.doQuery(b.getCurrentPage(), b.getPageSize(),
						b.getQParas(), b.getOParas(), (String[]) null,
						b.getShortNameMap(), b.getRetObjs(), (String[]) null);
				list = this.parseInBill(qr.getList(),
						this.inTypeDao.getList(false),
						this.storehouseDao.getList(false));
				qr.setList(list);
				ModelAndView mv = new ModelAndView(this.searchResultView);
				mv.addAllObjects(b.getParameters());
				mv.addObject("qr", qr);
				mv.addObject("inTypeList", this.inTypeDao.getList(true));
				UserBean ub = EncCommonHelper.getCurrentUserAccount(request);
				EnterpriseInfo ent = EncCommonHelper.getEnterpriseInfo(request);
				if (ent.getStorTs().equals("Y")) {
					mv.addObject("storehouseList",
							this.storehouseDao.getList(ub));
				} else {
					mv.addObject("storehouseList",
							this.storehouseDao.getList(true));
				}

				mv.addObject("tsList",
						PageHelper.getTallySetList(this.tallySetDao, ub));
				mv.addObject("costTotal", costTotal);
				return mv;
			}
		}
	}

	public ModelAndView handlePrint(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String id = request.getParameter("id");
		InBillBean bean = this.getInBill(Long.parseLong(id));
		ModelAndView mv = new ModelAndView(this.printView);
		mv.addObject("record", bean);
		mv.addObject("codeRule", this.codeRuleDao.get("IN_BILL"));
		mv.addObject("printCost", request.getParameter("print_cost"));
		return mv;
	}

	private List<?> parseInBill(List<?> list, List<?> inTypeList,
			List<?> storehouseList) {
		ArrayList arr = new ArrayList();

		for (int i = 0; i < list.size(); ++i) {
			InBill inBill = (InBill) list.get(i);
			InBillBean bean = new InBillBean();
			bean.setInBill(inBill);
			this.setInBillInfo(bean, inTypeList, storehouseList);
			arr.add(bean);
		}

		return arr;
	}

	private InBillBean getInBill(long id) {
		InBill inBill = (InBill) this.inBillDao.get(InBill.class, id);
		InBillBean form = new InBillBean();
		if (inBill != null) {
			List itemList = this.inBillItemDao.getList(inBill.getId());
			long[] productIds = new long[itemList.size()];

			for (int productList = 0; productList < itemList.size(); ++productList) {
				productIds[productList] = ((InBillItem) itemList
						.get(productList)).getProductId();
			}

			List arg12 = this.productDao.getList(productIds);
			ArrayList arr = new ArrayList();
			BigDecimal cost = new BigDecimal(0);

			for (int i = 0; i < itemList.size(); ++i) {
				InBillItemBean bean = new InBillItemBean();
				InBillItem item = (InBillItem) itemList.get(i);
				bean.setInBillItem(item);
				this.setProductInfo(arg12, bean);
				cost = cost.add(item.getCost());
				arr.add(bean);
			}

			form.setInBill(inBill);
			form.setItems(arr);
			form.setCost(cost);
			this.setInBillInfo(form, this.inTypeDao.getList(false),
					this.storehouseDao.getList(false));
		}

		return form;
	}

	private void setInBillInfo(InBillBean form, List<?> inTypeList,
			List<?> storehouseList) {
		InBill inBill = form.getInBill();
		if (inBill != null) {
			String offererName = "";
			if (inBill.getOffererType() != null && inBill.getOffererId() != 0L) {
				if (!inBill.getOffererType().equals("CLIENT")
						&& !inBill.getOffererType().equals("PROVIDER")
						&& !inBill.getOffererType().equals("COOPERATOR")) {
					if (inBill.getOffererType().equals("DEPARTMENT")) {
						Department d1 = (Department) this.inBillDao.get(
								Department.class, inBill.getOffererId());
						if (d1 != null) {
							offererName = d1.getDepartmentName();
						}
					} else if (inBill.getOffererType().equals("STOREHOUSE")) {
						Storehouse d2 = (Storehouse) this.inBillDao.get(
								Storehouse.class, inBill.getOffererId());
						if (d2 != null) {
							offererName = d2.getStoName();
						}
					} else if (inBill.getOffererType().equals("WORK_CENTER")) {
						WorkCenter d3 = (WorkCenter) this.inBillDao.get(
								WorkCenter.class, inBill.getOffererId());
						if (d3 != null) {
							offererName = d3.getWcName();
						}
					}
				} else {
					Establishment d = (Establishment) this.inBillDao.get(
							Establishment.class, inBill.getOffererId());
					if (d != null) {
						offererName = d.getEstName();
					}
				}
			}

			form.setOffererName(offererName);
			form.setInTypeName(EncCommonHelper.getSimpleObjectName(inTypeList,
					inBill.getInTypeId()));
			form.setStoName(EncCommonHelper.getSimpleObjectName(storehouseList,
					inBill.getStorehouseId()));
			if (inBill.getTallySetId() != 0L) {
				TallySet d4 = (TallySet) this.inBillDao.get(TallySet.class,
						inBill.getTallySetId());
				if (d4 != null) {
					form.setTallySetName(d4.getTitle());
				}
			}
		}

	}

	private void setProductInfo(List<?> productList, InBillItemBean cb) {
		String productName = "";
		long productId = cb.getInBillItem().getProductId();
		if (productId != 0L) {
			for (int j = 0; j < productList.size(); ++j) {
				Product p = (Product) productList.get(j);
				if (p.getId() == productId) {
					productName = p.getProductName();
					cb.setProductCode(p.getProductCode());
					cb.setProductName(productName);
					cb.setUnit(p.getUnit());
					break;
				}
			}
		}

	}

	public ModelAndView handleUploadForm(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.uploadFormView);
		String storehouseId = request.getParameter("storehouse_id");
		mv.addObject("storehouseId", storehouseId);
		return mv;
	}

	public ModelAndView handleDownloadTemplate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		long storehouseId = Long.parseLong(request
				.getParameter("storehouse_id"));
		List list = this.productDao.getListByStorehouseId(storehouseId);
		HashMap map = new HashMap();
		map.put("list", list);
		InBillTemplateExcelView v = new InBillTemplateExcelView();
		return new ModelAndView(v, map);
	}

	public ModelAndView handleImportItem(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String fileName = request.getParameter("file_name");
		File file = new File(this.getServletContext().getRealPath(fileName));
		String alertMsg = "";
		Document doc = DocumentHelper.createDocument();
		Element root = doc.addElement("body");
		String productCode = "";
		String amountStr = "";
		String priceStr = "";
		String mark = "";
		BigDecimal zero = new BigDecimal(0);
		BufferedInputStream in = null;

		try {
			in = new BufferedInputStream(new FileInputStream(file));
			HSSFWorkbook format = new HSSFWorkbook(new POIFSFileSystem(in));

			for (int i = 0; i < format.getNumberOfSheets(); ++i) {
				HSSFSheet arg45 = format.getSheetAt(i);

				for (int j = 1; j < arg45.getPhysicalNumberOfRows(); ++j) {
					HSSFRow output = arg45.getRow(j);
					if (output == null) {
						break;
					}

					HSSFCell cell = output.getCell(0);
					productCode = PageHelper.getCellVal(cell, 25);
					cell = output.getCell(3);
					amountStr = PageHelper.getCellVal(cell, 20);
					cell = output.getCell(4);
					priceStr = PageHelper.getCellVal(cell, 20);
					cell = output.getCell(5);
					mark = PageHelper.getCellVal(cell, 200);
					BigDecimal amount = new BigDecimal(0);
					BigDecimal price = new BigDecimal(0);

					try {
						if (amountStr != null && !amountStr.equals("")) {
							amount = new BigDecimal(amountStr);
						}
					} catch (Exception arg41) {
						;
					}

					try {
						if (priceStr != null && !priceStr.equals("")) {
							price = new BigDecimal(priceStr);
						}
					} catch (Exception arg40) {
						;
					}

					if (amount.compareTo(zero) != 0
							&& price.compareTo(zero) != 0) {
						Product p = this.productDao.get(productCode, true);
						if (p != null) {
							Element pro = root.addElement("pro");
							Element proId = pro.addElement("pro_id");
							proId.setText(String.valueOf(p.getId()));
							Element proCode = pro.addElement("pro_code");
							proCode.setText(p.getProductCode());
							Element proName = pro.addElement("pro_name");
							proName.setText(p.getProductName());
							Element proUnit = pro.addElement("pro_unit");
							proUnit.setText(p.getUnit());
							Element proAmount = pro.addElement("pro_amount");
							proAmount.setText(amount.toString());
							Element proPrice = pro.addElement("pro_price");
							proPrice.setText(price.toString());
							Element proMark = pro.addElement("pro_mark");
							proMark.setText(mark);
						}
					}
				}
			}
		} catch (Exception arg42) {
			alertMsg = "导入错误：" + arg42.getMessage();
			Element out = root.addElement("alert_msg");
			out.setText(alertMsg);
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception arg39) {
				;
			}

		}

		response.setContentType("text/xml");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Pragma", "no-cache");
		OutputFormat arg44 = OutputFormat.createPrettyPrint();
		arg44.setEncoding("utf-8");
		ServletOutputStream arg46 = response.getOutputStream();
		XMLWriter arg47 = new XMLWriter(arg46, arg44);
		arg47.write(doc);
		arg46.flush();
		arg46.close();
		return null;
	}

	public InBillService getInBillService() {
		return this.inBillService;
	}

	public void setInBillService(InBillService inBillService) {
		this.inBillService = inBillService;
	}

	public IdGenerator getIdGenerator() {
		return this.idGenerator;
	}

	public void setIdGenerator(IdGenerator idGenerator) {
		this.idGenerator = idGenerator;
	}

	public StockDao getStockDao() {
		return this.stockDao;
	}

	public void setStockDao(StockDao stockDao) {
		this.stockDao = stockDao;
	}

	public InTypeDao getInTypeDao() {
		return this.inTypeDao;
	}

	public void setInTypeDao(InTypeDao inTypeDao) {
		this.inTypeDao = inTypeDao;
	}

	public DataSource getDataSource() {
		return this.dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	public QueryDao getQueryDao() {
		return this.queryDao;
	}

	public void setQueryDao(QueryDao queryDao) {
		this.queryDao = queryDao;
	}

	public StockBalanceDao getStockBalanceDao() {
		return this.stockBalanceDao;
	}

	public void setStockBalanceDao(StockBalanceDao stockBalanceDao) {
		this.stockBalanceDao = stockBalanceDao;
	}

	public StorehouseDao getStorehouseDao() {
		return this.storehouseDao;
	}

	public void setStorehouseDao(StorehouseDao storehouseDao) {
		this.storehouseDao = storehouseDao;
	}

	public String getPrintView() {
		return this.printView;
	}

	public void setPrintView(String printView) {
		this.printView = printView;
	}

	public BusinessBillDao getBusinessBillDao() {
		return this.businessBillDao;
	}

	public void setBusinessBillDao(BusinessBillDao businessBillDao) {
		this.businessBillDao = businessBillDao;
	}

	public CodeRuleDao getCodeRuleDao() {
		return this.codeRuleDao;
	}

	public void setCodeRuleDao(CodeRuleDao codeRuleDao) {
		this.codeRuleDao = codeRuleDao;
	}

	public TallySetDao getTallySetDao() {
		return this.tallySetDao;
	}

	public void setTallySetDao(TallySetDao tallySetDao) {
		this.tallySetDao = tallySetDao;
	}
}